//
//  ChangePasswordNextViewController.m
//  JingXingApp
//
//  Created by 王亮 on 15/8/8.
//  Copyright (c) 2015年 王亮. All rights reserved.
//

#import "ChangePasswordNextViewController.h"

@interface ChangePasswordNextViewController ()

@end

@implementation ChangePasswordNextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self UI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)UI {
    
    self.view.backgroundColor = Color_Back_Gray;
    [self.rightBtn setTitle:@"取消" forState:UIControlStateNormal];
    
    CGFloat rate = 90.0f / 615.0f;
    CGFloat height = CGRectGetWidth(self.view.frame) * rate;
    UITextField *textField1 = [[UITextField alloc] initWithFrame:CGRectMake(0, 12, 100, height)];
    [self.view addSubview:textField1];
    textField1.placeholder = @"输入旧密码";
    [self addBackView:textField1];
    
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(textField1.frame) + 12, 100, height * 2)];
    [self.view addSubview:backView];
    [self addSecondBackView:backView];
    
    UIImage *image = [UIImage imageNamed:@"找回密码_03"];
    UIButton *nextBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(backView.frame) + 69.0f / 2, image.size.width / 2, image.size.height / 2)];
    [self.view addSubview:nextBtn];
    nextBtn.center = CGPointMake(CGRectGetWidth(self.view.frame) / 2, nextBtn.center.y);
    [nextBtn setBackgroundImage:image forState:UIControlStateNormal];
    [nextBtn setTitle:@"确认" forState:UIControlStateNormal];
    [nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
}

- (void)addBackView:(UITextField *)textField {
    
    CGRect frame = textField.frame;
    frame.size.width = CGRectGetWidth(self.view.frame) - 30;
    frame.origin.x = 15;
    textField.frame = frame;
    textField.backgroundColor = [UIColor whiteColor];
    textField.layer.borderColor = [UIColor lightGrayColor].CGColor;
    textField.layer.borderWidth = 0.5;
    textField.font = [UIFont systemFontOfSize:15];
    
    UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 43.0f / 2, CGRectGetHeight(textField.frame))];
    textField.leftView = leftView;
    textField.leftViewMode = UITextFieldViewModeAlways;
}

- (void)addLeftView:(UITextField *)textField {
    
    UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 43.0f / 2, CGRectGetHeight(textField.frame))];
    textField.leftView = leftView;
    textField.leftViewMode = UITextFieldViewModeAlways;
    textField.font = [UIFont systemFontOfSize:15];
}


- (void)addSecondBackView:(UIView *)backView {
    
    CGRect frame = backView.frame;
    frame.size.width = CGRectGetWidth(self.view.frame) - 30;
    frame.origin.x = 15;
    backView.frame = frame;
    backView.backgroundColor = [UIColor whiteColor];
    backView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    backView.layer.borderWidth = 0.5;
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, frame.size.height / 2, frame.size.width, 0.5)];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [backView addSubview:lineView];
    
    CGFloat height = frame.size.height / 2;

    UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, height)];
    [backView addSubview:textField2];
    [self addLeftView:textField2];
    textField2.placeholder = @"输入新密码";
    
    UITextField *textField3 = [[UITextField alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(textField2.frame) + 0.5, frame.size.width, height)];
    [backView addSubview:textField3];
    [self addLeftView:textField3];
    textField3.placeholder = @"再次输入新密码";
}

@end
